<!DOCTYPE html>
<html>
<#assign contextPath = request.contextPath/>
<head>
<meta charset="UTF-8">
<title>后台管理</title>
<link href="${contextPath}/css/bootstrap.min.css" rel="stylesheet">
<script type="text/javascript"
	src="${contextPath}/js/jquery-3.0.0.min.js"></script>
<script type="text/javascript" src="${contextPath}/js/bootstrap.min.js"></script>

<link href="${contextPath}/css/toastr.css" rel="stylesheet" />
<script src="${contextPath}/js/toastr.js"></script>
</head>

<body>
	<script>
		var msg = '${msg!}';
		var parammsg = '${Parameters.msg!}';
		if (msg != '') {
			toastr.info(msg);
		} else if (parammsg != '') {
			toastr.info(parammsg);
		}
	</script>
	<#include "/common/nav.html">
	<div class="container-fluid">
		<div class="row">
			<#include "/common/left.html">
			<div class="col-sm-9">
				<ol class="breadcrumb">
					<li class="active">主页</li>
				</ol>
				<div class="table-responsive">
					<table class="table table-striped">
						<thead>
							<tr>
								<th>序号</th>
								<th>分类</th>
								<th>投票名</th>
								<th>参与人数</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							<#list p.list as v>
							<tr>
								<td>${p.startNum+v_index+1}</td>
								<td>${v.voteType.vtName!}</td>
								<td>${v.vtitle!}</td>
								<td>${v.vturnout!}</td>
								<td>
									<button type="button" class="btn btn-default btn-sm"
										data-toggle="modal" data-target="#exampleModal"
										data-whatever="${v.vid}">
										<span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span>
										详情
									</button>
									<button type="button" class="btn btn-default btn-sm"
										onclick="javascript:location.href='${contextPath}/admin/editvote.action?id=${v.vid}'">
										<span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
										修改
									</button>
									<button type="button" class="btn btn-default btn-sm"
										data-id="${v.vid}" data-toggle="modal"
										data-target="#confirm-delete">
										<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
										删除
									</button>
								</td>
							</tr>
							</#list>
						</tbody>
					</table>
					<nav aria-label="Page navigation" style="text-align: center">
						<ul class="pagination">
							<li <#if !p.hasPrev>class="disabled"</#if>><a<#if
									p.hasPrev>
									href="mainvote.action?p.pageNum=${p.pageNum-1}"</#if>
									aria-label="Previous"> <span aria-hidden="true">上一页</span>
							</a></li> <#list 1..p.pageSum as i>
							<li <#if p.pageNum == i>class="active"</#if>><a
								href="mainvote.action?p.pageNum=${i}">${i}</a></li> </#list>
							<li <#if !p.hasNext>class="disabled"</#if>><a<#if
									p.hasNext>
									href="mainvote.action?p.pageNum=${p.pageNum+1}"</#if>
									aria-label="Next"> <span aria-hidden="true">下一页</span>
							</a></li>
						</ul>
					</nav>
				</div>
			</div>
		</div>
	</div>
	<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog"
		aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">请确认</div>
				<div class="modal-body">确认删除该记录吗？</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
					<a class="btn btn-danger btn-ok">删除记录</a>
				</div>
			</div>
		</div>
	</div>
	<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog"
		aria-labelledby="exampleModalLabel">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-label="Close">
						<span aria-hidden="true">×</span>
					</button>
					<h4 class="modal-title" id="exampleModalLabel">投票标题</h4>
					<button id="fat-btn" class="btn btn-primary" type="button">投票类型
					</button>
				</div>
				<div class="modal-body"></div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
				</div>
			</div>
		</div>
	</div>
	<script>
		$('#confirm-delete').on(
				'show.bs.modal',
				function(e) {
					$(this).find('.btn-ok').attr(
							'href',
							"deletevote.action?id="
									+ $(e.relatedTarget).data('id'));
				});
		$('#exampleModal').on(
				'show.bs.modal',
				function(event) {
					var button = $(event.relatedTarget); // 触发事件的按钮  
					var whatever = button.data('whatever'); // 解析出data-whatever内容  
					var modal = $(this);

					$.post("getvote.action", "id=" + whatever, function(r) {
						modal.find('.modal-title').text(r.vtitle);
						modal.find("#fat-btn").text(r.voteType.vtName);
						var ops = r.voteOptions;
						var modalbody = modal.find('.modal-body');
						modalbody.children().remove();
						for (var i = 0; i < ops.length; i++) {
							var op = ops[i];
							modalbody.append("<div class='op well well-sm'>"
									+ op.voText + "</div>");
						}
					});
					//modal.find('.modal-body input').val(recipient)
				})
	</script>
</body>

</html>